<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>鼓励金购买</title>
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<script src="__INDEX__/js/mui.min.js"></script>
	    <link href="__INDEX__/css/mui.min.css" rel="stylesheet"/>
		<link rel="stylesheet" href="__INDEX__/store/css/style.css" />
		<link rel="stylesheet" href="__INDEX__/store/css/newsj.css" />
	</head>
	<body class="sjindexcon">
		<header class="mui-bar mui-bar-nav">
		    <a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
		    <h1 class="mui-title">鼓励金购买</h1>
		</header>
		<div class="mui-content sjindexcon" style="padding-bottom: 20px;">
			<div class="dzyhq_gljbox">
				<div class="dzyhq_glj clearfix">
					<p class="mem_id">{$data_info.agent_name}</p>
					<p class="bt">鼓励金余额</p>
					<p class="mem_gljnum"><?php  echo substr($data_info['score'],0,strlen($data_info['score'])-2);?></p>
				</div>
			</div>
			<div class="mem_ordbox">
				<div class="bt"><i></i>请选择购买电子券金额</div>
				<ul class="dzyhq_list">
					<li data-val=10>
						<div class="left">¥<em>10</em></div>
						<div class="right"><em>100</em><br/>鼓励金</div>
					</li>
					<li data-val=30>
						<div class="left">¥<em>30</em></div>
						<div class="right"><em>300</em><br/>鼓励金</div>
					</li>
					<li data-val=50>
						<div class="left">¥<em>50</em></div>
						<div class="right"><em>500</em><br/>鼓励金</div>
					</li>
				</ul>
			</div>
			<div class="mui-input-row mui-radio mui-left">
				<input name="checkbox" id="checkbox" value="Item 1" type="radio" >
				<label><a href="#">鼓励金服务协议</a></label>
			</div>
			<div class="btnbox"><button type="button" class="dzyhq_btn">确定购买</button></div>
		</div> 
		<input type="hidden" name="pay_money" id="pay_money" />
		<input type="hidden" name="charge_type" id="charge_type" value="1"/>
	</body>
</html>
{include file="public/footer" /}
<script>
	$(".dzyhq_list li").click(function(){
		$(".active").removeClass("active");
		$(this).addClass("active");
		$("#pay_money").val($(this).data('val'));  
	})
	
	$(".dzyhq_btn").click(function(){
		var cz_money=$(".active").data("val"); 
		if(cz_money==undefined){
			layer.msg("请选择购买金额");
			return;
		}else{
			if($('#checkbox').is(':checked')==false) {
				    layer.msg('请勾选购买协议');
				    return;
			}
			var btnArray = ['不同意', '同意'];
				mui.confirm('1 购买鼓励金比例为1:10。<br/>2 鼓励金赠送及抵扣比例从1%~100%由您自定义设置。', '鼓励金电子优惠券购买须知', btnArray, function(e) {
					 if (e.index == 1) {
					 		$.ajax({
					         	type:"post",
					            url:"{:url('index/pay/score_pay')}",
								data:{
									pay_money: $("#pay_money").val(),
									charge_type: $("#charge_type").val(),
								},
					            success:function(data){
					            	if(data.code == 200){
					            		location.href = data.url;
					            	}else{
					            		layer.msg(data.msg);
					            	}
					                
					            },error:function(data){
					            	var a = data;
					            }
					    	});
					 }
			})
		}
		
	})
</script>